var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (l, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, l) {
              e.__proto__ = l;
            }) ||
          function (e, l) {
            for (var o in l)
              Object.prototype.hasOwnProperty.call(l, o) && (e[o] = l[o]);
          })(l, o);
      };
      return function (l, o) {
        function i() {
          this.constructor = l;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(l, o),
          (l.prototype =
            null === o
              ? Object.create(o)
              : ((i.prototype = o.prototype), new i()));
      };
    })(),
  MedicalView = (function (e) {
    function l() {
      var l = e.call(this) || this;
      return (
        (l.selectIndex = -1),
        (l.oriBloodListArr = []),
        (l.onFreeMedicalTreatmentFn = {
          caller: l,
          code: 1241,
          method: function (e) {
            ToastView.toastView(e.msg),
              0 == e.code &&
                (Laya.stage.event("GameMainView", "refreshMoney"),
                Laya.stage.event("GameMainView", "exp"),
                Laya.stage.event("HomePageView", "refreshMoney"),
                Laya.stage.event("HomePageView", "exp"));
          },
        }),
        (l.onChemicalRecoveryFn = {
          caller: l,
          code: 1245,
          method: function (e) {},
        }),
        l.btn_medicalBack.on(Laya.Event.CLICK, l, l.onMedicalPreBack),
        (l.tab_medical.selectHandler = new Laya.Handler(l, l.onSelectMedical)),
        l.initMedicalBloodView(),
        l.btn_freeFeedback.on(Laya.Event.CLICK, l, l.onFreeFeedbackFn),
        l.btn_medicalRecle.on(Laya.Event.CLICK, l, l.onMedicalRecleFn),
        (l.list_medical.selectEnable = !0),
        l.list_medical.on(Laya.Event.CLICK, l, l.setSelected),
        (l.list_medical.vScrollBarSkin = ""),
        WebSocketService.addListener(l.onFreeMedicalTreatmentFn),
        WebSocketService.addListener(l.onChemicalRecoveryFn),
        WebSocketService.addListener({
          caller: l,
          code: 1825,
          method: l.onLoadFuBenYaoPinData,
        }),
        l
      );
    }
    return (
      __extends(l, e),
      (l.openMedicalView = function () {
        return (
          null == this.medicalVC && (this.medicalVC = new l()),
          parseInt(Global.roleLvl) > 10
            ? (this.medicalVC.btn_freeFeedback.label = "全体治疗")
            : (this.medicalVC.btn_freeFeedback.label = "免费治疗"),
          (this.medicalVC.btn_freeFeedback.visible = !0),
          (this.medicalVC.btn_medicalRecle.visible = !0),
          this.medicalVC
        );
      }),
      (l.showFuBenMedicalView = function () {
        return (
          null == this.medicalVC && (this.medicalVC = new l()),
          (this.medicalVC.type = "fuben_yaopin"),
          (this.medicalVC.tab_medical.selectedIndex = 0),
          WebSocketService.send({ c: 1825, d: { type: 1 } }),
          (this.medicalVC.btn_freeFeedback.visible = !1),
          (this.medicalVC.btn_medicalRecle.visible = !1),
          this.medicalVC
        );
      }),
      (l.prototype.onFreeFeedbackFn = function (e) {
        "全体治疗" == e.target.label
          ? WebSocketService.send({ c: 1241, d: { qr: 9 } })
          : "免费治疗" == e.target.label &&
            WebSocketService.send({ c: 1241, d: { qr: 9 } });
      }),
      (l.prototype.onMedicalRecleFn = function () {
        var e = RecoverMedicalView.showRecoverView();
        e.pos(0, 70), Laya.stage.addChild(e);
      }),
      (l.prototype.initMedicalBloodView = function () {
        WebSocketService.addListener({
          caller: this,
          code: 600,
          method: function (e) {},
        }),
          WebSocketService.send({ c: 210, d: { no: 1 } }),
          (this.oriBloodListArr = [
            { bloID: "1", bloName: "跌打药", bloValue: "+500", bloPrice: 50 },
            { bloID: "2", bloName: "止血药", bloValue: "+1000", bloPrice: 60 },
            { bloID: "3", bloName: "金疮药", bloValue: "+1500", bloPrice: 70 },
            { bloID: "4", bloName: "麻沸散", bloValue: "+2000", bloPrice: 80 },
            { bloID: "5", bloName: "酥和散", bloValue: "+3000", bloPrice: 200 },
            {
              bloID: "6",
              bloName: "断续膏 ",
              bloValue: "+4500",
              bloPrice: 300,
            },
            { bloID: "7", bloName: "三黄丸", bloValue: "+6000", bloPrice: 400 },
            {
              bloID: "9",
              bloName: "熊胆丸",
              bloValue: "+10000",
              bloPrice: 600,
            },
            {
              bloID: "10",
              bloName: "首乌丸",
              bloValue: "+15000",
              bloPrice: 800,
            },
            {
              bloID: "11",
              bloName: "雪参丸",
              bloValue: "+20000",
              bloPrice: 1e3,
            },
            { bloID: "12", bloName: "小还丹", bloValue: "+25%", bloPrice: 200 },
            { bloID: "13", bloName: "大还丹", bloValue: "+50%", bloPrice: 450 },
            { bloID: "14", bloName: "护命丹", bloValue: "+75%", bloPrice: 700 },
            {
              bloID: "16",
              bloName: "九转丹",
              bloValue: "+100%",
              bloPrice: 1e3,
            },
          ]);
        for (var e, l = [], o = 0; o < this.oriBloodListArr.length; o++)
          (e = {
            medicalName: { text: this.oriBloodListArr[o].bloName },
            medicalValue: { text: this.oriBloodListArr[o].bloValue },
            medicalPrice: { label: this.oriBloodListArr[o].bloPrice + "银" },
            name: this.oriBloodListArr[o].bloID,
          }),
            l.push(e);
        this.list_medical.array = l;
      }),
      (l.prototype.initMedicalEneryView = function () {
        this.oriBloodListArr = [
          { bloID: "17", bloName: "回春汤", bloValue: "+500", bloPrice: 50 },
          { bloID: "18", bloName: "花蜜酒", bloValue: "+1000", bloPrice: 60 },
          { bloID: "19", bloName: "清泉酒", bloValue: "+1500", bloPrice: 70 },
          { bloID: "20", bloName: "菖蒲酒", bloValue: "+2000", bloPrice: 80 },
          { bloID: "21", bloName: "苦艾酒", bloValue: "+3000", bloPrice: 200 },
          { bloID: "22", bloName: "花雕酒 ", bloValue: "+4500", bloPrice: 300 },
          { bloID: "23", bloName: "杜康酒", bloValue: "+6000", bloPrice: 400 },
          { bloID: "24", bloName: "虎骨酒", bloValue: "+10000", bloPrice: 600 },
          { bloID: "26", bloName: "强生酒", bloValue: "+15000", bloPrice: 800 },
          { bloID: "27", bloName: "万古酒", bloValue: "+20000", bloPrice: 1e3 },
          { bloID: "28", bloName: "芸香露", bloValue: "+25%", bloPrice: 200 },
          { bloID: "29", bloName: "红莲露", bloValue: "+50%", bloPrice: 450 },
          { bloID: "31", bloName: "玄冰露", bloValue: "+75%", bloPrice: 700 },
          { bloID: "32", bloName: "龙涎露", bloValue: "+100%", bloPrice: 1e3 },
        ];
        for (
          var e, l = [], o = (this.getChildByName("medicalPrice"), 0);
          o < this.oriBloodListArr.length;
          o++
        )
          (e = {
            medicalName: { text: this.oriBloodListArr[o].bloName },
            medicalValue: { text: this.oriBloodListArr[o].bloValue },
            medicalPrice: { label: this.oriBloodListArr[o].bloPrice + "银" },
            name: this.oriBloodListArr[o].bloID,
          }),
            l.push(e);
        this.list_medical.array = l;
      }),
      (l.prototype.setSelected = function (e) {
        if ("medicalPrice" == e.target.name) {
          var l = this.list_medical.getCell(this.list_medical.selectedIndex),
            o =
              (l.getChildByName("medicalName"),
              l.getChildByName("medicalValue"),
              l.getChildByName("medicalPrice")),
            i = "",
            t = "",
            a = 0,
            r = !1;
          if ("fuben_yaopin" == this.type) {
            var c = this.list_medical.selectedItem;
            (i = c.id), (t = c.name), (a = c.price), (r = !0);
          } else
            (i = this.oriBloodListArr[this.list_medical.selectedIndex].bloID),
              (t =
                this.oriBloodListArr[this.list_medical.selectedIndex].bloName),
              (a = parseInt(o.label));
          BuyMedicalView.showMedical(t, a, i, r);
        }
      }),
      (l.prototype.onSelectMedical = function (e) {
        "fuben_yaopin" == this.type
          ? 0 == e
            ? WebSocketService.send({ c: 1825, d: { type: 1 } })
            : 1 == e && WebSocketService.send({ c: 1825, d: { type: 2 } })
          : 0 == e
          ? this.initMedicalBloodView()
          : this.initMedicalEneryView();
      }),
      (l.prototype.onMedicalPreBack = function () {
        this.removeSelf();
      }),
      (l.prototype.onLoadFuBenYaoPinData = function (e) {
        this.oriBloodListArr = e.data;
        for (var l, o = [], i = 0; i < this.oriBloodListArr.length; i++) {
          var t = this.oriBloodListArr[i];
          (l = {
            medicalName: { text: t.name },
            medicalValue: { text: "" },
            medicalPrice: { label: t.buy_price + "银" },
            name: t.name,
            id: t.id,
            price: t.price,
          }),
            o.push(l);
        }
        this.list_medical.array = o;
      }),
      l
    );
  })(ui.HospitalController.MedicalViewUI);
